using SG3L_RAG.Domain.Entities;
using SG3L_RAG.Application.DTOs;

namespace SG3L_RAG.Application.Interfaces
{
    public interface IUserService
    {
        // 基本 CRUD 操作
        Task<User?> GetByIdAsync(Guid id);
        Task<User?> GetByUsernameAsync(string username);
        Task<User?> GetByEmailAsync(string email);
        Task<IEnumerable<User>> GetAllAsync();
        Task<User> CreateAsync(string username, string password, string email, string phoneNumber, string role);
        Task<User> CreateAsync(string username, string password, string email, string role); // 兼容旧接口
        Task UpdateAsync(User user);
        Task<User> UpdateUserAsync(Guid userId, UpdateUserDto updateUserDto);
        Task DeleteAsync(Guid id);
        
        // 角色和权限操作
        Task<IEnumerable<User>> GetUsersByRoleAsync(string role);
        Task<bool> IsAdminAsync(Guid userId);
        Task<bool> IsNormalUserAsync(Guid userId);
        Task<bool> HasPermissionAsync(Guid userId, Guid documentId, string permissionType);
        Task AddPermissionAsync(Guid userId, Permission permission);
        
        // 密码和验证操作
        Task<bool> ValidateCredentialsAsync(string username, string password);
        Task<bool> CheckPasswordAsync(Guid userId, string inputPassword);
        Task ChangePasswordAsync(Guid userId, string newPassword);
        
        // 用户信息更新操作
        Task UpdatePhoneNumberAsync(Guid userId, string phoneNumber);
        Task UpdateEmailAsync(Guid userId, string email);
        Task UpdateAvatarAsync(Guid userId, string? avatar);
        
        // 关联实体操作
        Task AddDocumentAsync(Guid userId, Document document);
        Task AddConversationAsync(Guid userId, Conversation conversation);
        Task<IEnumerable<Document>> GetUserDocumentsAsync(Guid userId);
        Task<IEnumerable<Conversation>> GetUserConversationsAsync(Guid userId);
        Task<IEnumerable<Permission>> GetUserPermissionsAsync(Guid userId);
    }
}
